package weak_20241227_29.stream;


import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author zdl
 * @date 2024/12/28
 */
public class Demo17 {
    public static void main(String[] args) {
        //17. 将整数列表中的数字分为奇数和偶数，分别存储在不同的列表中
        ArrayList<Integer> list  = new ArrayList<>();
        list.add(1);
        list.add(2);
        list.add(3);
        list.add(4);
        list.add(5);
        list.add(6);
        List<Integer> collect1 = list.stream().filter(s -> s % 2 == 0).collect(Collectors.toList());
        List<Integer> collect2 = list.stream().filter(s -> s % 2 != 0).collect(Collectors.toList());
        System.out.println(collect1);
        System.out.println(collect2);
    }
}
